import 'package:flutter/material.dart';
import 'tags/title.dart';

class CardWidget extends StatelessWidget {
  final Widget? title;
  final Widget? footer;
  final Widget? child;

  final Color color;
  final double borderRadius;
  final String? titleText;
  final double elevation;
  final EdgeInsetsGeometry? padding;
  final EdgeInsetsGeometry? margin;

  const CardWidget({
    Key? key,
    this.title,
    this.footer,
    this.child,
    this.titleText,
    this.color = Colors.white,
    this.elevation = 0,
    this.borderRadius = 5,
    this.padding = const EdgeInsets.all(10),
    this.margin,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Card(
      color: color,
      margin: margin,
      elevation: elevation,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
      ),
      child: Container(
        padding: padding,
        child: Column(
          children: [
            if (title != null || titleText != null)
              title ??
                  Row(
                    children: <Widget>[TagTitle(titleText!)],
                  ),
            if (title != null || titleText != null)
              const Divider(
                thickness: 0.5,
                height: 1,
              ),
            if (child != null) child!,
            if (child != null && footer != null)
              const Divider(
                thickness: 0.5,
                height: 1,
              ),
            if (footer != null) footer!,
          ],
        ),
      ),
    );
  }
}
